async function exam_get() {
  try {
    let url = 'study/get_term_exam_arrange';
    var res = await getApp().xutils.request(url, null);
    wx.setStorage({
      key: 'exam',
      data: res.data.data
    });
    getApp().globalData.exam = res.data.data;
  } catch (error) {
    console.log(error);
  }
}

function exam_manage(exam) {
  var examInfo = {};
  var endArrange = {}; //已安排
  var noEndArrange = []; //未安排
  var end = []; //已完成
  var noEnd = []; //未完成
  var today = new Date();
  var dayTemp = new Date();
  for (var i in exam) {
    if (exam[i].status == -1 || exam.status == 0) {
      noEndArrange.push(exam[i]);
    } else if (exam[i].status == 1) {
      var examTime = exam[i].examTime.split(" ")[0];
      var time = examTime.split("-");
      dayTemp.setFullYear(time[0], parseInt(time[1] - 1), time[2]);
      if (today > dayTemp) {
        end.push(exam[i]);
      } else {
        noEnd.push(exam[i]);
      }
    }
  }
  endArrange.end = end;
  endArrange.noEnd = noEnd;
  examInfo.endArrange = endArrange;
  examInfo.noEndArrange = noEndArrange;
  return examInfo;
}


module.exports.exam_get = exam_get;
module.exports.exam_manage = exam_manage;